package com.itcc.dao;

import com.itcc.domain.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookDao {

    @Insert("insert into tb_book (type, name, description) values (#{type}, #{name}, #{description})")
    public int insert(Book book);

    @Delete("delete from tb_book where id=#{id}")
    public int delete(@Param("id")Integer id);

    @Update("update tb_book set type=#{type}, name=#{name}, description=#{description} where id=#{id}")
    public int update(Book book);

    @Select("select * from tb_book where id=#{id}")
    public Book findById(@Param("id")Integer id);

    @Select("select * from tb_book")
    public List<Book> selectAll();

    @Select("select * from tb_book where name like CONCAT('%', #{name}, '%')")
    public List<Book> selectOther(@Param("name") String name);
}
